package com.bawei.jetpackdemo.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;

import com.bawei.jetpackdemo.R;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;

/**
 * @Author : yaotianxue
 * @Time : On 2023/9/11 09:26
 * @Description : MyDialog
 */
public class MyDialog extends Dialog implements LifecycleObserver {
    public MyDialog(@NonNull Context context) {
        super(context);
    }

    public MyDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected MyDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_dialog);
    }
    //感知activity的生命周期做出相应的操作
    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    public void destroy(){
        dismiss();
    }



}
